import request from "@/utils/request"

export enum AdvInfoType {
  电站 = 1,
  优惠券 = 2,
  无 = 3,
}

export enum AdvShow {
  展示 = 1,
  隐藏 = 2,
}

export enum AdvOpenType {
  轮播图 = 1,
  弹窗 =2,
}

export enum AdvPlaceType {
  小程序首页 = 1,
  商城板块首页 =2,
}

export interface QueryAdvListParams extends PaginationParams {
  openType?: AdvOpenType
  placeType?: AdvPlaceType
  infoType?: AdvInfoType
  isShow?: AdvShow
}

export interface Adv {
  createTime: number
  id: number
  infoId: string
  /** 关联信息名称 */
  infoName: string
  infoType: AdvInfoType
  isShow: AdvShow
  /** 权重 */
  power: number
  openType: AdvOpenType
  placeType?: AdvPlaceType
  pic: string
}

export async function queryAdvList(params: QueryAdvListParams) {
  return request<Adv[]>('/app/manager/banner/list', {
    data: params,
  })
}

export async function editAdv(params: Partial<Adv>) {
  return request('/app/manager/banner/addOrUp', {
    data: params,
  })
}

export async function delAdv(params: {
  id: number, 
  status: 1 | 2 | 3, // 1:显示，2-隐藏，3-删除
}) {
  return request('/app/manager/banner/upStatus', {
    data: params,
  })
}
